package com.emm.yixun.mobile.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.emm.yixun.mobile.R;
import com.emm.yixun.mobile.model.GetSubscribeDetail.AnnexList;

public class AnnexAdapter extends BaseAdapter {

	ArrayList<AnnexList> list;

	Activity c;

	public AnnexAdapter(Activity c, ArrayList<AnnexList> list) {
		this.list = list;
		this.c = c;
	}

	@Override
	public int getCount() {
		return list == null ? 0 : list.size();
	}

	@Override
	public Object getItem(int position) {
		return list == null ? null : list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHd v = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(c).inflate(R.layout.focus_item, null);
			v = new ViewHd();
			v.spinner_name = (TextView) convertView.findViewById(R.id.spinner_name);
			v.select_image_att = (ImageView) convertView.findViewById(R.id.select_image_att);
			v.imageView1_delete = (ImageView) convertView.findViewById(R.id.imageView1_delete);
			v.count_textview = (TextView) convertView.findViewById(R.id.count_textview);
			v.focus_item_lines = convertView.findViewById(R.id.focus_item_lines);
			convertView.setTag(v);
		} else {
			v = (ViewHd) convertView.getTag();
		}
		v.spinner_name.setText(list.get(position).getAnnexName());
		if ((list.size() - 1) == position) {
			v.focus_item_lines.setVisibility(View.VISIBLE);
		} else {
			v.focus_item_lines.setVisibility(View.GONE);
		}
		v.count_textview.setTextColor(Color.parseColor("#909090"));
		v.count_textview.setTextSize(15);
		v.imageView1_delete.setVisibility(View.GONE);
		return convertView;
	}

	public static class ViewHd {
		TextView spinner_name, count_textview;

		ImageView select_image_att, imageView1_delete;

		View focus_item_lines;
	}

}
